package cloud.xcan.angus.extension.angustester.deepseek.plugin;

import cloud.xcan.angus.extension.angustester.deepseek.api.TranslationService;
import cloud.xcan.angus.spec.locale.SupportedLanguage;

public class DeepSeekTranslationServiceTest {

  public static void main(String[] args) {
    // Programmatic configuration with custom retry settings
    DeepSeekConfig config = new DeepSeekConfig("");
    config.setMaxRetries(5); // Allow up to 5 retries
    config.setInitialRetryDelayMs(500); // Start with 500ms delay
    config.setBackoffFactor(1.5); // Linear backoff factor

    TranslationService translator = new DeepSeekTranslationService(config);

    try {
      String result = translator.translate("       ## API Specification\n"
          + "        \n"
          + "        AngusTester is built on **RESTful design principles** and strictly adheres to the [OpenAPI 3.0](https://swagger.io/specification/v3/) specification format.\n"
          + "\n"
          + "        ### 1. Protocol Specification\n"
          + "        \n"
          + "        - **Mandatory HTTPS Usage**  \n"
          + "          APIs are always served over HTTPS to ensure secure data transmission.  \n"
          + "          > **Note**: Private deployment customers may not have security certificates configured and require separate handling.\n"
          + "\n"
          + "        - **API Version Management**  \n"
          + "          Version numbers are embedded in URL paths:  \n"
          + "          ```\n"
          + "          /api/v1/resource\n"
          + "          /api/v2/resource\n"
          + "          ```\n"
          + "\n"
          + "        ### 2. Resource Naming Convention\n"
          + "        \n"
          + "        - Uniformly use **lowercase letters** or **lower camel case naming**  \n"
          + "        - Examples:  \n"
          + "          ```\n"
          + "          /user\n"
          + "          /productCategories\n"
          + "          /orderItems\n"
          + "          ```\n"
          + "\n"
          + "        ### 3. HTTP Method Specification\n"
          + "          | Method      | Description                              | Success Code | Example                   |\n"
          + "          |-------------|------------------------------------------|--------------|---------------------------|\n"
          + "          | **GET**     | Retrieve resources                       | 200          | `GET /users`              |\n"
          + "          | **POST**    | Create resources                         | 201          | `POST /users`             |\n"
          + "          | **PUT**     | Replace entire resource (create if absent)| 200          | `PUT /users/{id}`         |\n"
          + "          | **PATCH**   | Partial resource update                  | 200          | `PATCH /users/{id}`       |\n"
          + "          | **DELETE**  | Delete resources                         | 204          | `DELETE /users/{id}`      |\n"
          + "        \n"
          + "        **Special Operation Patterns** - Use verbs/adjectives for granular operations:  \n"
          + "          ```\n"
          + "          PATCH /users/{id}/enabled   # Enable user\n"
          + "          POST /orders/{id}/cancel    # Cancel order\n"
          + "          ```\n"
          + "\n"
          + "        ### 4. Security Authentication\n"
          + "        \n"
          + "        **OAuth 2.0 Authentication** - Protected resources require authentication header:  \n"
          + "        \n"
          + "        ```\n"
          + "        Authorization: Bearer <access_token>\n"
          + "        ```\n"
          + "\n"
          + "        ### 5. Request Parameter Specification\n"
          + "        \n"
          + "        #### Request Headers\n"
          + "          ```\n"
          + "          Content-Type: application/json\n"
          + "          Accept: application/json\n"
          + "          Authorization: Bearer xxxxxxxxxxxx\n"
          + "          ```\n"
          + "\n"
          + "        #### Query Parameters\n"
          + "          | Parameter Type | Format Example                      | Description          |\n"
          + "          |----------------|-------------------------------------|----------------------|\n"
          + "          | Pagination     | `?pageNo=2&pageSize=20`             | Page number and size |\n"
          + "          | Sorting        | `?orderBy=createdDate&orderSort=DESC` | Sort field and direction |\n"
          + "          | Filtering      | `?status=active&role=admin`         | Field filters        |\n"
          + "        \n"
          + "        #### Request Body (JSON)\n"
          + "          ```json\n"
          + "          {\n"
          + "            \"name\": \"John Doe\",\n"
          + "            \"email\": \"john@example.com\",\n"
          + "            \"role\": \"member\",\n"
          + "            \"preferences\": {\n"
          + "              \"notifications\": true,\n"
          + "              \"theme\": \"dark\"\n"
          + "            }\n"
          + "          }\n"
          + "          ```\n"
          + "\n"
          + "        ### 6. Response Specification\n"
          + "        \n"
          + "        #### Status Codes\n"
          + "          | Code | Meaning                          |\n"
          + "          |------|----------------------------------|\n"
          + "          | 200  | OK - Request succeeded           |\n"
          + "          | 201  | Created - Resource created       |\n"
          + "          | 204  | No Content - Success, no content |\n"
          + "          | 400  | Bad Request - Client error       |\n"
          + "          | 401  | Unauthorized - Not authenticated |\n"
          + "          | 403  | Forbidden - Access denied        |\n"
          + "          | 404  | Not Found - Resource not exist   |\n"
          + "          | 429  | Too Many Requests - Rate limited |\n"
          + "          | 500  | Internal Server Error - Server failure |\n"
          + "        \n"
          + "        #### Response Body Structure\n"
          + "          ```json\n"
          + "          {\n"
          + "            \"code\": \"S\",\n"
          + "            \"msg\": \"Operation succeeded\",\n"
          + "            \"data\": {\n"
          + "              \"total\": 42,\n"
          + "              \"list\": [\n"
          + "                {\n"
          + "                  \"id\": \"301222970049691648\",\n"
          + "                  \"username\": \"U20250628001287\",\n"
          + "                  \"email\": \"user@example.com\"\n"
          + "                }\n"
          + "              ]\n"
          + "            },\n"
          + "            \"datetime\": \"2025-06-15 14:49:56\",\n"
          + "            \"ext\": {}\n"
          + "          }\n"
          + "          ```\n"
          + "\n"
          + "        ## Quick Start Guide\n"
          + "\n"
          + "        ### 1. Obtaining Access Tokens\n"
          + "        \n"
          + "        #### System Access Token\n"
          + "          **Use Case**: System-to-system integration  \n"
          + "          **Acquisition Process**:\n"
          + "          1. Log in to AngusGM application\n"
          + "          2. Navigate to: **System** → **System Tokens**\n"
          + "          3. Create new token:\n"
          + "             - Enter token name\n"
          + "             - Set permission scope\n"
          + "             - Configure expiration time\n"
          + "          4. Click **Create Token** to generate new credentials\n"
          + "        \n"
          + "          > **Note**: System tokens have full API permissions without data restrictions.\n"
          + "\n"
          + "        #### User Access Token\n"
          + "          **Use Case**: User-level API operations  \n"
          + "          **Acquisition Process**:\n"
          + "          1. Log in to AngusGM application\n"
          + "          2. Access: **User Profile** → **Access Tokens**\n"
          + "          3. Create new token:\n"
          + "             - Verify user password\n"
          + "             - Set token name\n"
          + "             - Configure validity period\n"
          + "          4. Click **Create Token** to generate credentials\n"
          + "        \n"
          + "          > **Note**: User tokens inherit the user's API permissions and data access rights.\n"
          + "\n"
          + "        ### 2. API Service Endpoints\n"
          + "          | Deployment Type   | Service Endpoint                     |\n"
          + "          |-------------------|--------------------------------------|\n"
          + "          | SaaS Cloud Edition| `https://bj-c1-prod-apis.xcan.cloud/tester` |\n"
          + "          | Private Deployment| `http://TESTER_HOST:TESTER_PORT` (default)   |\n"
          + "          |                   | Or configured via `TESTER_APIS_URL_PREFIX` |\n"
          + "\n"
          + "        ### 3. API Call Example\n"
          + "          ```bash\n"
          + "          curl -i 'https://bj-c1-prod-apis.xcan.cloud/tester/api/v1/task/search?pageNo=1&pageSize=10' \\\n"
          + "            -H 'Accept: application/json'\n"
          + "            -H 'Authorization: Bearer 7RProMAjgCr40gMgrsnRROvMXHrXrDrzwqo7ti1V2ZXc6bjoWvVEOTkjbQnLAxMTi5fJrnET' \n"
          + "          ```\n"
          + "\n"
          + "        **Response Example**:\n"
          + "          ```http\n"
          + "          HTTP/1.1 200 OK\n"
          + "          Date: Sun, 15 Jun 2025 06:49:56 GMT\n"
          + "          Content-Type: application/json\n"
          + "          XC-Request-Id: 34acb65c2c484188a2f9f3a3f4ca3d1f\n"
          + "        \n"
          + "          {\n"
          + "            \"code\": \"S\",\n"
          + "            \"msg\": \"Success\",\n"
          + "            \"data\": {\n"
          + "              \"total\": \"1\",\n"
          + "              \"list\": [\n"
          + "                {\n"
          + "                  \"id\": \"301222970049691648\",\n"
          + "                  \"code\": \"AT00000016\",\n"
          + "                  \"name\": \"A Task\"\n"
          + "                }\n"
          + "              ]\n"
          + "            },\n"
          + "            \"datetime\": \"2025-06-15 14:49:56\"\n"
          + "          }", SupportedLanguage.zh_CN);
      System.out.println("Translation: " + result);
    } catch (Exception e) {
      System.err.println("Translation failed: " + e.getMessage());
    }
  }

}
